{include file="public/header" /}
<body class="activity-lottery-winning">
        <div id="loader" style="text-align: center;height:30px;line-height: 30px;background: white;display: none;"><img src="__ROOT__/static/chou/images/load.gif" align="absmiddle"/> 请稍后，数据传输中 ...</div>
        <div  class="main"  >
         
            <div id="outercont">
                <div id="outer-cont">
                    <div id="outer"><img src="__ROOT__/static/chou/images/zp8-.png"></div>
                </div>
                <div id="inner-cont">
                    <div id="inner"><img src="__ROOT__/static/chou/images/activity-lottery-2.png"></div>
                </div>
                <div class="boxcontent boxwhite">
                    <div class="box">
                        <div class="title-red">活动说明：</div>
                        <div class="Detail">
                            <p >本次活动时间仅在一天内生效！</p>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <script type="text/javascript">
            $(function(){
                window.requestAnimFrame = (function(){
                    return window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame ||
                         function(callback) {
                            window.setTimeout(callback, 1000 / 60);
                          };
                })();
                var totalDeg = 360 * 5 + 0;
                var steps = [];

                var lostDeg = [120, 240, 360];
                var prizeDeg = [40, 80, 160, 200, 280, 320];
                var prize,sncode;
                var count = 0;
                var now = 0;
                var a = 0.01;
                var outter, inner, timer, running = false;
                function countSteps() {
                    var t = Math.sqrt(2 * totalDeg / a);
                    var v = a * t;
                    for (var i = 0; i < t; i++) {
                        steps.push((2 * v * i - a * i * i) / 2);
                    }
                    steps.push(totalDeg);
                }
                function step(){
                    outter.style.webkitTransform = 'rotate(' + steps[now++] + 'deg)';
                    outter.style.MozTransform = 'rotate(' + steps[now++] + 'deg)';
                    if (now < steps.length){
                        running = true;
                        requestAnimFrame(step);
                    } else {
                        alert(rname);
                        //console.log(rname);
                        running = false;
                    }
                }
                function start(deg) {
                    deg = deg || lostDeg[parseInt(lostDeg.length * Math.random())];
                    running = true;
                    clearInterval(timer);
                    totalDeg = 360 * 5 + deg;
                    steps = [];
                    now = 0;
                    countSteps();
                    requestAnimFrame(step);
                }
                window.start = start;
                outter = document.getElementById('outer');
                inner = document.getElementById('inner');
                i = 1;
                $("#inner").click(function(){

                    if (running)
                        return;
//                    $('#loader').show();
//                    $('#inner-cont').css('top', '148px');
                    
                    $.get("{:url('user/lottery_json')}",function(data){
                        var rid = data.rid;//抽奖id
                        var re=data.re;//抽奖次数
                        var fen=data.fen;//积分
                        rname = data.rname;
//                        $('#loader').hide();
//                        $('#inner-cont').css('top', '118px');
                    
                       if(fen ==1){
                         alert("积分不足,不能抽奖");
                        }else{
                        if(re ==1){
                         alert("今日抽奖次数已用完");
                        }else{
                          if (rid == 0){
                            start();
                          }else{
                           start(prizeDeg[rid - 1]);
                          }
                       }
                     }
                },"json");
                    
                    
                    
                    
                    
                 });
            });
        </script>
    </body>
</html>
